package com.goldenKey.admin.controller;

import com.goldenKey.common.pojo.result.R;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.goldenKey.common.pojo.po.Review;
import com.goldenKey.admin.service.IReviewService;

/**
 * @Author: 吃我一钊
 * @Description: 控制层
 * @Date: 2025/02/02
 */
@RestController
@RequestMapping("/review")
public class ReviewController {

	@Autowired
	private IReviewService reviewService;

	/**
	 * 新增数据
	 * @param review
	 * @return
	 */
	@PostMapping("/save")
	public R<Void> save(@RequestBody Review review) {
		reviewService.save(review);
		return R.ok();
	}

	/**
	 * 根据id删除
	 * @param reviewId
	 * @return
	 */
	@DeleteMapping("/deleteById/{reviewId}")
	public R<Void> deleteById(@PathVariable("reviewId") Integer reviewId) {
		reviewService.removeById(reviewId);
		return R.ok();
	}

	/**
	 * 根据id修改数据
	 * @param review
	 * @return
	 */
	@PutMapping("/updateById")
	public R<Void> updateById(@RequestBody Review review) {
		reviewService.updateById(review);
		return R.ok();
	}

	/**
	 * 根据id查询数据
	 * @param reviewId
	 * @return
	 */
	@GetMapping("/getById/{reviewId}")
	public R<Review> getById(@PathVariable("reviewId") Integer reviewId) {
		Review review = reviewService.getById(reviewId);
		return R.ok(review);
	}
	/**
	 * 查询所有数据
	 * @return
	 */
	@GetMapping("/list")
	public R<List<Review>> list() {
		List<Review> reviewList = reviewService.list();
		return R.ok(reviewList);
	}

}